/**
 * Created by Will Bean on 2016/4/25.
 */
import React, { Component,PropTypes } from 'react'
//import

class InputWithLabel extends Component{
    constructor(props){
        super(props);
        this.state = {
            message: this.props.val? this.props.val : ""
        }
    }

    handleChange(e){
        this.setState({message : e.target.value})
    }

    render(){
        const { inputClass , labelName, placeholder, id } = this.props;
        var message = this.state.message;
        return (
            <div className={inputClass ? inputClass : "input-div"}>
                <label>{labelName? labelName : ""}</label>
                <input type="text" id={id} placeholder={placeholder} value={message} onChange={this.handleChange.bind(this)}/>
            </div>
        )
    }
}

InputWithLabel.propTypes = {
    id: PropTypes.string.isRequired,
    placeholder: PropTypes.string.isRequired
};

export default InputWithLabel;